package com.zyt.hadoop;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @author zyt
 * @createDate 2020/09/14 11:31 AM
 */
public class HadoopReducer extends Reducer<IntWritable, NullWritable, IntWritable, IntWritable> {
    IntWritable index = new IntWritable();
    int sum = 1;

    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        index.set(sum++);
        context.write(index, key);
    }
}

